package ru.compscicenter.databases.zaikina.common.commands;


import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import ru.compscicenter.databases.zaikina.common.commands.bodies.EmptyCommandBody;

public class EmptyCommand extends SysCommand<Object, EmptyCommandBody> {
    public EmptyCommand(Integer type) {
        super(type, null, -1);
    }

    public EmptyCommand(Integer type, Integer param) {
        super(type, null, param);
    }

    public static EmptyCommand parse(String jsonStr) {
        JSONObject obj = (JSONObject) JSONValue.parse(jsonStr);
        if (SysCommandType.isEmptyCommand(SysCommand.parseType(obj))) {
            Integer type = Integer.parseInt(obj.get("type").toString());
            Integer param = Integer.parseInt(obj.get("param").toString());
            return new EmptyCommand(type, param);
        }
        return null;
    }
}
